<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>酒店列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <style>
        #guide_ul li{
            margin-top: 15px;
        }
        .layui-hide{  /*最后的pic为字段的field*/
            height: 100%;
            max-width: 100%;
        }
        .layui-table-cell{
            height:auto !important;
        }
        .test:nth-child(1){
            margin-left: 20px;
        }
    </style>
</head>
<body>
<div id="aaa"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">酒店列表</div>
                <div class="layui-card-body">
                    <div class="layui-form-item layui-form">

                        <div class="layui-inline">
                            <div class="layui-inline">
                                <div class="layui-btn-group test-table-operate-btn">
                                    <button class="layui-btn" data-type="addadmin">入驻酒店/民宿</button>
                                </div>
                            </div>
                        </div>
                        {if !empty($res)}
                        <div class="layui-inline">
                            <label class="layui-form-label">酒店名称</label>
                            <div class="layui-input-block">
                                <select name="tour_name" lay-verify="" lay-search id="tour_name">
                                    <option value="">请选择</option>
                                    {foreach $res as $k=>$v}
                                    <option value="{$v['hotel_name']}">{$v['hotel_name']}</option>
                                    {/foreach}
                                </select>
                            </div>
                            <!--<div class="layui-input-block">-->
                                <!--<input type="text" name="tour_name" id="tour_name" placeholder="请输入" autocomplete="off" class="layui-input">-->
                            <!--</div>-->
                        </div>
                        {/if}
                        <div class="layui-inline">
                            <label class="layui-form-label">酒店电话</label>
                            <div class="layui-input-block">
                                <input type="text" name="tour_tel" id="tour_tel" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">酒店类型</label>
                            <div class="layui-input-block">
                                <select name="kind_type" lay-filter="aihao" id="kind_types">
                                    <option value=""></option>
                                    <option value="1">星级酒店</option>
                                    <option value="2">名宿客栈</option>
                                    <option value="3">快捷宾馆</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">好评率</label>
                            <div class="layui-input-block">
                                <input type="text" name="appraise" id="appraise" placeholder="如果是好评段 请用~分割" autocomplete="off" class="layui-input" style="width: 220px">
                            </div>
                        </div>
                          <div class="layui-inline">
                            <label class="layui-form-label">入驻时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="create_time" id="test6" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>    
                        <div class="layui-inline">
                            <div class="layui-btn-group test-table-operate-btn">
                                <button class="layui-btn" data-type="searchUserButton">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
                        <script type="text/html" id="is_use_switch">
                            <input type="checkbox" name="is_login" lay-skin="switch" lay-text="推荐|不推荐" lay-filter="is_use_switch" value="{{ d.is_tuijian }}" data-json="{{ encodeURIComponent(JSON.stringify(d)) }}" {{ d.is_tuijian == 1 ? 'checked' : '' }}>
                        </script>
                         <script type="text/html" id="is_use_switchs">
                            <input type="checkbox" name="is_login" lay-skin="switch" lay-text="置顶|不置顶" lay-filter="is_use_switchs" value="{{ d.is_stick }}" data-json="{{ encodeURIComponent(JSON.stringify(d)) }}" {{ d.is_stick == 1 ? 'checked' : '' }}>
                        </script>
                        <script type="text/html" id="is_display_switch">
                            <input type="checkbox" name="is_display" lay-skin="switch" lay-text="上架|下架" lay-filter="is_display_switch" value="{{ d.is_display }}" data-json="{{ encodeURIComponent(JSON.stringify(d)) }}" {{ d.is_display == 0 ? 'checked' : '' }}>
                        </script>
                    </table>
                    <script type="text/html" id="test-table-operate-barDemo">

                        {{# if(d.is_rest==1){ }}
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="rest">休息</a>
                        {{# }else{ }}
                        <a class="layui-btn layui-btn-normal layui-btn-xs" >营业</a>
                        {{# } }}

                        <a class="layui-btn layui-btn-xs" lay-event="showDetail">详情</a>
                        <a class="layui-btn layui-btn-xs" lay-event="default">预定须知</a>
                        <a class="layui-btn layui-btn-normal layui-btn-xs" id="showImg" lay-event="showImg">图片</a><!-- 酒店图片 -->

                        <a class="layui-btn layui-btn-green layui-btn-xs" lay-event="editPassword">修改密码</a>
                         <a class="layui-btn layui-btn-green layui-btn-xs" lay-event="editPhone">修改手机号</a>
                        <a class="layui-btn layui-btn-green layui-btn-xs" lay-event="edit">修改</a>
                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="yesPass">添加相册</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="guide_del">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="contentShow" style="display:none;padding: 30px;">
    <p id="consultation"></p>
</div>
<!--添加弹窗-->
<div id="addmodal" style="display: none;padding:20px;">


    <div class="layui-upload">
        <button type="button" class="layui-btn layui-btn-normal" id="test-upload-testList">选择多文件</button>
        <input type="hidden" value="" id="hotel_id">
        <div class="layui-upload-list">
            <table class="layui-table">
                <thead>
                <tr><th>文件名</th>
                    <th>大小</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr></thead>
                <tbody id="test-upload-demoList"></tbody>
            </table>
        </div>
        <button type="button" class="layui-btn" id="test-upload-testListAction">开始上传</button>
    </div>

</div>

<!--导游信息详情-->
<div id="userDetail" style="display: none;padding:20px;">
    <div class="userDetailCen">
        <ul id="guide_ul">
            <li>
                <p class="p-user">酒店地址：<span id="address"></span></p>
            </li>
            <li>
                <p class="p-user">酒店类型：<span id="kind_type"></span></p>
            </li>
            <li>
                <p class="p-user">酒店标签：<span id="hotel_tag"></span></p>
            </li>
            <li>
                <p class="p-user">酒店介绍：<span id="hotel_subject"></span></p>
            </li>

            <li>
                <p class="p-user">店铺状态：<span  id="is_rest" style="color: red"></span></p>
            </li>
            <!--<li>-->
                <!--<p class="p-user" id="rest_why">店铺原因：<span   style="color: red"></span></p>-->
            <!--</li>-->
            <!--<li>-->
                <!--<p class="p-user" id="ff">闭店时间：<span  id="close" style="color: red"></span></p>-->
            <!--</li>-->
            <!--<li>-->
                <!--<p class="p-user" id="vv">闭店时长：<span  id="close_time" style="color: red"></span></p>-->
            <!--</li>-->

            <li>
                <p class="p-user">法人身份证：</p>
                <img src="" id="fs_lagal1" style="width: 160px;height: 100px">
                <img src="" id="fs_lagal2" style="width: 160px;height: 100px;margin-left: 15px">
            </li>
            <li>
                <p class="p-user">营业执照：</p>
                <img src="" id="business_license" style="width: 160px;height: 100px"/>
            </li>
            <li>
                <p class="p-user">酒店门头照：</p>
                <img src="" id="m_image" style="width: 160px;height: 100px"/>
            </li>
            <li>
                <p class="p-user">酒店吧台照：</p>
                <img src="" id="b_image" style="width: 160px;height: 100px"/>
            </li>

            <li>
                <p class="p-user">实景图片：</p>
                <div id="live_action">

                </div>

            </li>
        </ul>
    </div>
</div>
<!--导游信息详情-->
<div id="rest" style="display: none;padding:20px;">
    <div class="userDetailCen">
        <ul id="rests">
            <li>
            <p class="p-user" id="rest_why">店铺原因：<span id="why"  style="color: red"></span></p>
            </li>
            <li>
            <p class="p-user" id="ff">闭店时间：<span  id="close" style="color: red"></span></p>
            </li>
            <li>
            <p class="p-user" id="vv">闭店时长：<span  id="close_time" style="color: red"></span></p>
            </li>

        </ul>
    </div>
</div>

<!--修改密码-->
<div id="editpassmodal"  style="display: none;padding:20px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" lay-verify="password" id="editPassword" placeholder="6-12位字母、数字、常用字符" autocomplete="off" class="layui-input">
                <input type="hidden" name="h_admin_id"  id="editPasswordUid">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" lay-verify="password" id="editPasswordAgin"  placeholder="再次输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-inline" style="left: 0;">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="editpasssubmit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
    </form>
</div>
<!--修改手机号-->
<div id="editpassmodals"  style="display: none;padding:20px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="phone"  id="editPhone" value="" autocomplete="off" class="layui-input">
                <input type="hidden" name="h_admin_id"  id="hotel">
                <input type="hidden" name="hotel_name"  id="hotel_name">
            </div>
        </div>


        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-inline" style="left: 0;">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="editphonesubmit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
    </form>
</div>

<!--提示信息-->
<div id="title"  style="display: none;padding:20px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <p style="text-align: center;font-size: 16px">该店铺有待确认，待核销的订单如下，是否确认下架，确认后将会按原路退款给用户，该商家将不会再app或者pc端显示</p>
        <div class="layui-form-item" style="margin-top: 25px">
            <label class="layui-form-label" style="width: 150px">待确认订单数： <span id="yes_order" style="color: red"></span></label>
        </div>
        <input type="hidden" id="ho_id"/>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 150px">待核销订单数：<span id="cancel_order" style="color: red"></span></label>
        </div>
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label" style="width: 150px">待退款订单数：<span id="refund_order" style="color: red"></span></label>-->
        <!--</div>-->
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 150px">退款总金额：<span id="money" style="color: red"></span></label>
        </div>
        <div class="layui-form-item layui-layout-admin">
            <div style="text-align: center;margin-top: 20px">
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="submits">确认</button>
                <button class="layui-btn layui-btn-primary" lay-filter="quxiao">取消</button>
            </div>
        </div>
    </form>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
        layui.use('laydate', function(){
      var laydate = layui.laydate;  
      //日期范围
      laydate.render({
        elem: '#test6'
        ,range: true
      }); 
    }); 
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set','upload'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form,
            upload = layui.upload;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Merchant/hotel')}"
            ,height: 'full-155'
            ,cols: [[
                {field:'hotel_id',align:'center', title: 'ID'}
                ,{field:'hotel_name',align:'center',title: '酒店名称'}
                ,{field:'hotel_covers',width:120,align:'center',title: '酒店封面图',style:"height:100px;",templet:function(d){
                        return "<img src=" +d.hotel_covers+ ">"}}
                ,{field:'hotel_tel',align:'center',title: '酒店电话'}
                ,{field:'kind_type',align:'center',title: '酒店类型'}
                ,{field:'send_tel',align:'center',title: '接收短信手机号'}
               
                // ,{field:'address', align:'center', title: '酒店地址',templet:function (d) {
                //         return d.city+d.address
                //     }}
                ,{field:'examine_time', align:'center', title: '入驻时间'}
                ,{field:'evaluat_rate', align:'center', title: '好评率'}
                //,{field:'commission_rate',align:"center",title: '商家佣金比例(双击可修改)',edit: 'text',style:'cursor: pointer;'}
                // ,{field:'sort',align:"center",title: '权重(双击可修改)',edit: 'text',style:'cursor: pointer;'}
                ,{field:'is_stick',width:100, align:'center', title: '是否置顶',templet: '#is_use_switchs'}
                ,{field:'is_tuijian',width:100, align:'center', title: '是否推荐',templet: '#is_use_switch'}
                ,{field:'is_display', align:'center', title: '是否上架',templet: '#is_display_switch'}
                ,{align:'center',width:630, title: '操作', toolbar: '#test-table-operate-barDemo'}
            ]]
            ,page:true
            ,limit:10
        });

        form.render();

        laydate.render({
            elem: '#search_time'
        });
        //开关修改管理员状态
        form.on('switch(is_use_switch)', function(obj){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var json = JSON.parse(decodeURIComponent($(this).data('json')));
            json = table.clearCacheKey(json);
            
            var is_tuijian = this.checked ? '1' : '0';

            $.ajax({
                url: "{:url('Merchant/isHotelTj')}",
                type: 'post',
                dataType: 'json',
                data: {id:json.hotel_id,is_tuijian:is_tuijian},
                success: function(info){
                    if (info.code === 1) {
                        layer.closeAll()

                    }else{
                        layer.msg(info,{icon:2,time:1000},function(){
                            //layer.close(loading);
                            window.location.reload();
                        });
                    }
                }
            })
        });
         //开关修改管理员状态
        form.on('switch(is_use_switchs)', function(obj){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var json = JSON.parse(decodeURIComponent($(this).data('json')));
            json = table.clearCacheKey(json);

            var is_stick = this.checked ? '1' : '0';

            $.ajax({
                url: "{:url('Merchant/isStickTj')}",
                type: 'post',
                dataType: 'json',
                data: {id:json.hotel_id,is_stick:is_stick},
                success: function(info){
                    if (info.code === 1) {
                        layer.closeAll()

                    }else{
                        layer.msg(info,{icon:2,time:1000},function(){
                            //layer.close(loading);
                            window.location.reload();
                        });
                    }
                }
            })
        });
        //多文件列表示例
        var demoListView = $('#test-upload-demoList')
            ,uploadListIns = upload.render({
            elem: '#test-upload-testList'
            ,url: "{:url('Merchant/uploadsImg')}"
            ,accept: 'file'
            ,data:{
                id: function(){
                    return $('#hotel_id').val();
                }
            }
            ,multiple: true
            ,auto: false
            ,bindAction: '#test-upload-testListAction'
            ,choose: function(obj){
                var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function(index, file, result){
                    var tr = $(['<tr id="upload-'+ index +'">'
                        ,'<td>'+ file.name +'</td>'
                        ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
                        ,'<td>等待上传</td>'
                        ,'<td>'
                        ,'<button class="layui-btn layui-btn-mini test-upload-demo-reload layui-hide">重传</button>'
                        ,'<button class="layui-btn layui-btn-mini layui-btn-danger test-upload-demo-delete">删除</button>'
                        ,'</td>'
                        ,'</tr>'].join(''));

                    //单个重传
                    tr.find('.test-upload-demo-reload').on('click', function(){
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.test-upload-demo-delete').on('click', function(){
                        delete files[index]; //删除对应的文件
                        tr.remove();
                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                    });

                    demoListView.append(tr);
                });
            }
            ,done: function(res, index, upload){
                if(res.code == 0){ //上传成功
                    var tr = demoListView.find('tr#upload-'+ index)
                        ,tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                    tds.eq(3).html(''); //清空操作
                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                }
                this.error(index, upload);
            }
            ,error: function(index, upload){
                var tr = demoListView.find('tr#upload-'+ index)
                    ,tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.test-upload-demo-reload').removeClass('layui-hide'); //显示重传
            }
        });
        form.on('switch(is_display_switch)', function(obj){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var json = JSON.parse(decodeURIComponent($(this).data('json')));
            json = table.clearCacheKey(json);

            var is_display = this.checked ? '0' : '1';
            if(is_display==0){
                $.ajax({
                    url: "{:url('Merchant/isTourShow')}",
                    type: 'post',
                    dataType: 'json',
                    data: {id:json.hotel_id,is_display:is_display},
                    success: function(info){
                        if (info.code === 1) {
                            layer.closeAll()

                        }else{
                            layer.msg(info.msg,{icon:2,time:2000},function(){
                                //layer.close(loading);
                                window.location.reload();
                            });
                        }
                    }
                })
            }else{
                //查看有无核销订单或者待确认的订单
                $.ajax({
                    url: "{:url('Merchant/isOrder')}",
                    type: 'post',
                    dataType: 'json',
                    data: {id:json.hotel_id},
                    success: function(info){
                        if (info.code === 1) {
                            layer.open({
                                content: '该店铺已无核销和确定订单 下架后 将不会再app或者pc端展示 确定要下架吗？'
                                ,btn: ['确定', '取消',]
                                ,yes: function(index, layero){
                                    $.ajax({
                                        url: "{:url('Merchant/isXj')}",
                                        type: 'post',
                                        dataType: 'json',
                                        data: {id:json.hotel_id,is_display:1},
                                        success: function(info){
                                            if (info.code === 1) {
                                                layer.closeAll();
                                                window.location.reload();
                                            }else{
                                                layer.msg(info.msg,{icon:2,time:2000},function(){
                                                    //layer.close(loading);
                                                    window.location.reload();
                                                });
                                            }
                                        }
                                    })
                                }
                                ,btn2: function(index, layero){
                                    //按钮【按钮二】的回调
                                    layer.closeAll();
                                    window.location.reload();
                                    //return false 开启该代码可禁止点击该按钮关闭
                                }
                                ,cancel: function(){
                                    //右上角关闭回调
                                    layer.closeAll();
                                    window.location.reload();
                                    //return false 开启该代码可禁止点击该按钮关闭
                                }
                            });
                        }
                        if(info.code ===2){
                            $('#yes_order').html(info.q_sum);
                            $('#cancel_order').html(info.h_sun);
                            //$('#refund_order').html(info.t_sun);
                            $('#money').html(info.all_money);
                            $('#ho_id').val(info.id);
                            var editpassmodal = layer.open({
                                title:'下架信息提示'
                                ,type: 1
                                ,shadeClose: true
                                ,area: admin.screen() < 2 ? ['60%'] : ['500px']
                                ,content: $('#title')
                                ,cancel: function(index, layero){

                                    layer.close(index);
                                    window.location.reload();
                                    return false;
                                }
                            });
                        }
                    }
                })
            }

        });
        //取消
        form.on('submit(quxiao)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            layer.closeAll();
            window.location.reload();
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //确认并退款
        form.on('submit(submits)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var id = $("#ho_id").val();
            $.ajax({
                url: "{:url('Merchant/isRefund')}",
                type: 'post',
                dataType: 'json',
                data: {id:id},
                success: function(info){
                    if (info === "1") {
                        layer.msg('下架成功',{icon:1,time:2000},function(){
                            layer.closeAll();
                            window.location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //监听单元格编辑
        table.on('edit(test-table-operate)', function(obj) {
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var reg = /^\d{1,4}$/;
            if (!reg.test(obj.value)) {
                layer.close(loading);
                layer.msg('请输入1-4位数字',{icon:2,time:1500},function(){
                    window.location.reload();
                });

                return false;
            }   
            $.ajax({
                url: "{:url('Merchant/editHotelSort')}",
                type: 'post',
                dataType: 'json',
                data: {id:obj.data.hotel_id,sort:obj.value},
                success: function(msg){
                    layer.close(loading);
                    if (msg.code == "0") {
                        layer.close(loading);
                    }else{
                        layer.close(loading);
                        layer.msg(msg.code,{icon:2,time:1500},function(){
                            window.location.reload();
                        });
                    }

                }
            })

        });
        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data;
            if(obj.event === 'showDetail'){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var hotel_id = data.hotel_id;
                $.ajax({
                    url: "{:url('Merchant/hotelInfoDetail')}",
                    type: 'post',
                    dataType: 'json',
                    data: {hotel_id:hotel_id},
                    success: function(data){
                        layer.close(loading);
                        if (data.code === 0) {
                            if(data.data.address === ''){
                                 $('#address').html('未设置');
                             }else{
                                var address = data.data.city+data.data.address
                                $('#address').html(address);
                             }
                            if(data.data.kind_type==""){
                                $('#kind_type').html('未设置');
                            }else{
                                $('#kind_type').html(data.data.kind_type);
                            }
                            if(data.data.hotel_tag ==""){
                                $('#hotel_tag').html('未设置');
                            }else{
                                $('#hotel_tag').html(data.data.hotel_tag);
                            }
                            if(data.data.hotel_subject==''){
                                $('#hotel_subject').html('未设置');
                            }else{
                                $('#hotel_subject').html(data.data.hotel_subject);
                            }
                            if(data.data.is_rest==0){
                                $('#is_rest').html('营业中');
                                $('#ff').hide();
                                $('#vv').hide();
                                $('#rest_why').hide();
                            }else{
                                $('#is_rest').html('休息中');
                                $('#close').html(data.data.rest_time);
                                $('#rest_why').html(data.data.rest_why);
                                var start_time = new Date(data.data.rest_time);
                                var time1 = start_time.getTime();
                                var time2 = new Date().valueOf();
                                var ms = time2 - time1;
                                var colse_time = Math.floor(ms/1000/60/60);
                                $('#close_time').html(colse_time+"小时");
                            }
                            //处理身份证图片
                            var img_src = data.data.fs_lagal;
                            var img_src_arr = img_src.split(',');
                            $('#fs_lagal1').attr('src',img_src_arr[0]);
                            $('#fs_lagal2').attr('src',img_src_arr[1]);
                            //导游照片
                            $('#business_license').attr('src',data.data.business_license);
                            $('#m_image').attr('src',data.data.m_image);
                            $('#b_image').attr('src',data.data.b_image);
                            var live = data.data.live_action;
                            var live_src = live.split(',');
                            var show = '';

                            $.each(live_src,function (i) {
                                $("#live_action img").remove();
                                show+='<img src="'+live_src[i]+'"  style="width: 160px;height: 100px;margin-left: 20px;">';
                                $("#live_action").append(show);
                            })


                            var userDetailModal = layer.open({
                                title:'酒店信息详情'
                                ,type: 1
                                ,shadeClose: true
                                ,area:['800px','500px']
                                ,content: $('#userDetail')
                            });
                        }else{
                            layer.msg('获取信息失败',{icon:2,time:1000});
                        }


                    }
                })
            } else if(obj.event === 'showImg'){
                $.ajax({
                    url: "{:url('Merchant/hotelImage')}",
                    type: 'post',
                    dataType: 'json',
                    data: {id:data.hotel_id},
                    success: function(msg){
                        if (msg.code == 0) {
                            console.log(msg.data);
                            var arr  = msg.data;
                            let img_src_arr = [];
                            for (var i in arr) {
                                img_src_arr.push(arr[i].img_path)
                            }
                            console.log(img_src_arr);
                            var img_src_data = {};
                            img_src_data.title = '酒店图片';
                            img_src_data.id = data.id;
                            img_src_data.start = 0;
                            img_src_data.data =[];

                            var src = {};

                            for(var i=0;i<img_src_arr.length;i++){
                                src = {};
                                var num = i+1;
                                src.alt = '酒店图片'+ num;
                                src.pid = i;
                                src.src = img_src_arr[i];
                                src.thumb = img_src_arr[i];
                                console.log(src);
                                img_src_data.data.push(src);
                            }
                            layer.photos({
                                photos: img_src_data
                                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                            });
                        }else{
                            layer.msg(msg.message,{time:1000});
                        }
                    }
                });
            } else if(obj.event === 'guide_del'){
                layer.confirm('确认删除"' + data.hotel_name + '"吗？', function(index){
                    var loading = layer.load(1, {
                        shade: [0.1,'#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: "{:url('Merchant/delHotel')}",
                        type: 'post',
                        dataType: 'json',
                        data: {id:data.hotel_id},
                        success: function(msg){
                            layer.close(loading);
                            if (msg.code == 0) {
                                obj.del();
                                layer.close(index);
                            }else{
                                layer.msg(msg.message,{icon:2,time:1000});
                            }
                        }
                    });
                });
            } else if(obj.event === 'editPassword'){
                $('#editPasswordUid').val(data.h_admin_id);
                var editpassmodal = layer.open({
                    title:'修改商户密码'
                    ,type: 1
                    ,shadeClose: true
                    ,area: admin.screen() < 2 ? ['60%'] : ['500px']
                    ,content: $('#editpassmodal')
                });
            }else if(obj.event === 'edit'){
                window.location.href="{:url('Merchant/editHotel')}?id=" + data.hotel_id;
            }else if(obj.event === 'yesPass'){
                //top.layui.index.openTabsPage("{:url('Merchant/upload_hotel')}?id=" + data.hotel_id,data.hotel_name+'添加相册');
                $('#hotel_id').val(data.hotel_id);
                var addmodal = layer.open({
                    title: '图片上传'
                    , type: 1
                    , shadeClose: false
                    , area: ['700px','600px']
                    , content: $('#addmodal')
                    ,cancel:function(){
                        window.location.reload();
                    }

                });
            }else if(obj.event === 'default'){
                window.open("/api/details/hotel/id/"+data.hotel_id+".html")
            }else if(obj.event === 'editPhone'){
                $('#hotel').val(data.hotel_id);
                $('#editPhone').val(data.send_tel);
                $('#hotel_name').val(data.hotel_name);
                var editphonemodal = layer.open({
                    title:'修改商户手机号'
                    ,type: 1
                    ,shadeClose: true
                    ,area: admin.screen() < 2 ? ['60%'] : ['500px']
                    ,content: $('#editpassmodals')
                });
            }else if(obj.event === 'rest'){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var hotel_id = data.hotel_id;
                $.ajax({
                    url: "{:url('Merchant/hotelInfoDetail')}",
                    type: 'post',
                    dataType: 'json',
                    data: {hotel_id:hotel_id},
                    success: function(data){
                        layer.close(loading);
                        if (data.code === 0) {
                            $('#close').html(data.data.rest_time);
                            $('#why').html(data.data.rest_why);
                            var start_time = new Date(data.data.rest_time);
                            var time1 = start_time.getTime();
                            var time2 = new Date().valueOf();
                            var ms = time2 - time1;
                            var colse_time = Math.floor(ms/1000/60/60);
                            $('#close_time').html(colse_time+"小时");


                            var userDetailModal = layer.open({
                                title:'闭店详情'
                                ,type: 1
                                ,shadeClose: true
                                ,area:['400px']
                                ,content: $('#rest')
                            });
                        }else{
                            layer.msg('获取信息失败',{icon:2,time:1000});
                        }


                    }
                })
            }

        });
        //修改密码提交
        form.on('submit(editpasssubmit)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var password = $('#editPassword').val();
            var passwordAgin = $('#editPasswordAgin').val();
            if (password !== passwordAgin){
                layer.close(loading);
                layer.msg('两次输入的密码不同',{icon:2,time:1000});
                return false;
            }
            $.ajax({
                url: "{:url('Merchant/editHotelPass')}",
                type: 'post',
                dataType: 'text',
                data: {data:data.field},
                success: function(info){
                    if (info === "1") {
                        layer.msg('修改成功',{icon:1,time:2000},function(){
                            layer.closeAll()
                        });
                    }else{
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //修改手机号
         form.on('submit(editphonesubmit)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            var phone = $('#editPhone').val();
            var myreg=/^1\d{10}$/;
            if (!myreg.test(phone)) {
                layer.msg('请输入正确的手机号',{icon:2,time:1000},function(){
                            layer.closeAll()
                        });
                return false;
            } 
            $.ajax({
                url: "{:url('Merchant/editHotelTel')}",
                type: 'post',
                dataType: 'text',
                data: {data:data.field},
                success: function(info){
                    if (info === "1") {
                        layer.msg('修改成功',{icon:1,time:2000},function(){
                            layer.closeAll()
                        });
                    }else if(info === "3"){
                         layer.msg('手机号已经存在',{icon:2,time:2000},function(){
                            layer.closeAll()
                        });
                    }
                    else if(info === "2"){
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        var $ = layui.$, active = {
            addadmin: function() {
                window.location.href="{:url('Merchant/hotelAdd')}";
            },
            searchUserButton:function(){
                var tour_name  = $('#tour_name').val();
                var tour_tel = $('#tour_tel').val();
                var kind_type = $('#kind_types').val();
                var appraise = $('#appraise').val();
                var examine_time = $("#test6").val();
                table.reload('test-table-operate', {
                    where: {
                        tour_name:tour_name,
                        tour_tel: tour_tel,
                        kind_type:kind_type,
                        appraise:appraise,
                        examine_time:examine_time
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>